package memento.improve;

public class Client {
    public static void main(String[] args) {
        Caretaker caretaker = new Caretaker();
        String name1 = "东东";
        String name2 = "西西";
        System.out.println("BOSS战开始前");
        Originator originator1 = new Originator(name1, 100, 100);
        Originator originator2 = new Originator(name2, 50, 50);
        //保存状态
        caretaker.addMemento(name1, "BOSS战开始前", originator1.saveToMemento());
        caretaker.addMemento(name2, "BOSS战开始前", originator2.saveToMemento());

        // BOSS战后
        System.out.println("BOSS战结束后");
        originator1.setVit(50);
        originator1.setDef(50);
        originator2.setVit(30);
        originator2.setDef(30);
        caretaker.addMemento(name1, "BOSS战结束后", originator1.saveToMemento());
        caretaker.addMemento(name2, "BOSS战结束后", originator2.saveToMemento());

        // 休息,回满血
        System.out.println("休息，回满血");
        originator1.setVit(200);
        originator1.setDef(200);
        originator2.setVit(100);
        originator2.setDef(100);


        // 恢复状态--开战之前
        System.out.println("恢复到BOSS战前");
        Memento memento = caretaker.getMemento(name1, "BOSS战开始前");
        originator1.restoreFromMemento(memento);

    }
}
